package com.yoyo.schedule;


public class Schedules {

    /**
     * baseTaskType + Constants.$ + ownSign=taskType
     */
    public static String getTaskType(String baseTaskType, String ownSign) {
        return baseTaskType + Constants.$ + ownSign;
    }

    public static String getBaseTaskType(String taskType) {
        return taskType.substring(0, taskType.indexOf(Constants.$));
    }

    public static String getOwnSign(String taskType) {
        return taskType.substring(taskType.indexOf(Constants.$) + 1);
    }

    /**
     * 分配
     */
    public static int[] allot(int taskItemNum, int serverNum) {
        int[] ints = new int[serverNum];
        int num = taskItemNum / serverNum;
        int left = taskItemNum % serverNum;
        for (int i = 0; i < ints.length; i++) {
            if (i < left) {
                ints[i] = num + 1;
            } else {
                ints[i] = num;
            }
        }
        return ints;
    }

}
